using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class vCurrencyRateMap : EntityTypeConfiguration<vCurrencyRate>
    {
        public vCurrencyRateMap()
        {
            // Primary Key
            this.HasKey(t => new { t.ID, t.SYMBOL });

            // Properties
            this.Property(t => t.ID)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.DESCRIP)
                .HasMaxLength(20);

            this.Property(t => t.SYMBOL)
                .IsRequired()
                .HasMaxLength(5);

            // Table & Column Mappings
            this.ToTable("vCurrencyRates");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.DESCRIP).HasColumnName("DESCRIP");
            this.Property(t => t.SYMBOL).HasColumnName("SYMBOL");
            this.Property(t => t.DATE).HasColumnName("DATE");
            this.Property(t => t.RateLL).HasColumnName("RateLL");
            this.Property(t => t.RateUSD).HasColumnName("RateUSD");
        }
    }
}
